package com.lyon.custom.parse;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;

import java.util.List;
import java.util.Map;

/**
 * @author LeeYan9
 * @since 2021-11-26
 */
public class LyonDataParseProcessorHolder {

    private static Map<String, LyonDataParseProcessor> parseProcessorMap;
    private static List<String> types;

    public static Map<String, String> parseData(String content, String fileExt) {
        LyonDataParseProcessor parseProcessor = parseProcessorMap.get(fileExt);
        if (nonParse(fileExt)) {
            return MapUtil.empty();
        }
        return parseProcessor.parse(content);
    }

    private static boolean nonParse(String fileExt) {
        if (CollUtil.isEmpty(types) || !types.contains(fileExt)) {
            return false;
        }
        return true;
    }

}
